//package com.tkmybatis.hfy.aop;
//
//import java.lang.reflect.Method;
//import javax.servlet.http.HttpServletRequest;
//import org.aspectj.lang.ProceedingJoinPoint;
//import org.aspectj.lang.annotation.Around;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Pointcut;
//import org.aspectj.lang.reflect.MethodSignature;
//import org.springframework.stereotype.Component;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//import cn.cmcc.es.exception.ErrorType;
//import cn.cmcc.es.exception.EsException;
//import cn.cmcc.es.hfy.annotation.NoRequestSubmit;
//import cn.cmcc.es.hfy.redis.RedisUtils;
//import cn.cmcc.es.hfy.utils.HttpUtil;
//
//@Aspect
//@Component
//public class RepeatSubmitAspect {
//
//	@Pointcut("@annotation(cn.cmcc.es.hfy.annotation.NoRequestSubmit)")
//	public void pointCut() {
//
//	}
//
//	@Around("pointCut()")
//	public Object around(ProceedingJoinPoint pjp) throws Throwable {
//		MethodSignature signature = (MethodSignature) pjp.getSignature();
//		Method method = signature.getMethod();
//		NoRequestSubmit noRequestSubmit = method.getAnnotation(NoRequestSubmit.class);
//		int lockSeconds = noRequestSubmit.lockTime();
//		ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
//		if(attributes != null) {
//			HttpServletRequest request = attributes.getRequest();
//			String accessToken = HttpUtil.getToken(request);
//			String path = request.getServletPath();
//			String key = accessToken + "-" + path;
//			String oldKey = (String) RedisUtils.get(key);
//			if(oldKey != null) {
//				//重复请求
//				throw new EsException(ErrorType.REQUEST_SUBMIT);
//			}
//			RedisUtils.set(key, key, lockSeconds);
//		}
//		return pjp.proceed();
//	}
//
//}
